#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <cstring>
#include <string>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cmath>
using namespace std;

const double dlt = 1e-11;
vector<double>a, b, c;
int n;

inline double f(double x) {
	double ans = a[1] * x * x + b[1] * x + c[1];
	for (int i = 1; i < a.size(); i++)
		ans = max(ans, a[i] * x * x + b[i] * x + c[i]);
	return ans;
}

void ac() {
	int T;
	cin >> T;
	while (T--) {
		cin >> n;
		a.resize(n + 1, 0);
		b = c = a;
		for (int i = 1; i <= n; i++)
			cin >> a[i] >> b[i] >> c[i];

		double l = 0, r = 1000.0;
		while (r - l > dlt) {
			double m1 = f(l + (r - l) / 3),
				m2 = f(r - (r - l) / 3);
			if (m1 <= m2)
				r = r - (r - l) / 3;
			else
				l = l + (r - l) / 3;
		}
		printf("%.4lf\n", f(r));
	}

}

int main() {
	ac();
	return 0;
}
